package com.exigenservices.demenkov.controllers;

import com.exigenservices.demenkov.model.services.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;


@Controller
public class ViewController {
    @Autowired
    private NewsService newsService;


    @RequestMapping(value = "view")
    protected ModelAndView handleRenderRequest(RenderRequest request,
                                               RenderResponse response) throws Exception {
        ModelAndView modelAndView = new ModelAndView("LargeNews");
        modelAndView.addObject("latestnews", newsService.getLatestNews(5));
        return modelAndView;
    }
}
